package org.example.gradleadmin.feigns.fallback;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.example.gradleadmin.feigns.service.GradleOrderFeignClient;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * fallback
 */
@Slf4j
@Component
public class GradleOrderFallbackFactory implements FallbackFactory<GradleOrderFeignClient> {

    @Override
    public GradleOrderFeignClient create(Throwable cause) {

        return new GradleOrderFeignClient() {
            @Override
            public boolean buy(String userId) {
                log.error("【member-service】 GradleOrderFeignClient buy() exception = {}", ExceptionUtils.getStackTrace(cause));
                return false;
            }

            @Override
            public boolean buy2(String userId) {
                log.error("【member-service】 GradleOrderFeignClient buy2() exception = {}", ExceptionUtils.getStackTrace(cause));
                return false;
            }

        };
    }
}
